<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge" />
<link rel="shortcut icon" href="static/style/images/favicon.ico" />
<!-- [EasyUI] -->
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/gray/easyui.css" />
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/icon.css" />
<script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
<!-- [扩展样式] -->
<link rel="stylesheet" type="text/css" href="/static/css/dreamlu.css" />
<link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
<link rel="stylesheet" type="text/css" href="/static/css/login.css" />
<!--<script type="text/javascript" src="static/js/login.js" charset="utf-8"></script>-->
<title>用户管理</title>
<script type="text/javascript">
    var dataGrid;

    $(function () {
		//批量导入界面
        $("#sortDialog").dialog({
            title: "新增",
            width: ' 300px',
            height: '200px',
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '保存',
                handler: function () {
                    savesort();
                }
            }, {
                text: '关闭',
                handler: function () {

                    $("#sortDialog").dialog("close");
                }
            }]
        });
	    //用户维护（新增、修改）界面
        $("#userDialog").dialog({
            title: "新增",
            width: '60%',
            height: '70%',
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '保存',
                handler: function () {
                    saveUser();
                }
            }, {
                text: '关闭',
                handler: function () {

                    $("#userDialog").dialog("close");
                }
            }]
        });
        //首次进入拉取
        dataGrid = $('#dataGrid').datagrid({
            url: '/gettikulist',
            method:'get',
            fit: true,
            striped: true,
            rownumbers: true,
            pagination: true,
            singleSelect: true,
            idField: 'id',
            sortName: 'order_id',
            sortOrder: 'asc',
            pageSize: 30,
            pageList: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
            frozenColumns:[[
                {
                    width: '80',
                    title: ' id',
                    field: 'id',
                    hidden: true,
                },
                {
                    width: '80',
                    title: '排序ID',
                    field: 'order_id'
                },{
                    width: '80',
                    title: '题目ID',
                    field: 'sub_id',
                    sortable: true
                }, {
                    width: '80',
                    title: '车辆类型',
                    field: 'car_type'
                },{
                    width: '80',
                    title: '科目',
                    field: 'exam_type',
                    formatter: function (value, row, index) {
                        if (row.exam_type=='1'){
                            return '科目一'
                        }else{
                            return '科目四'
                        }

                    }
                },{
                    width: '80',
                    title: '章节',
                    field: 'sub_chapte'
                }
                ]],
            columns: [[{
                width: '80',
                title: 'VIP',
                field: 'vip',
            },{
                width: '80',
                title: 'VIP排序',
                field: 'vip_id',
            }, {
                width: '200',
                title: '题目',
                field: 'sub_title',
            }, {
                width: '80',
                title: '题目图片',
                field: 'sub_pic',
            },{
                width: '80',
                title: '题目属性',
                field: 'sub_class'
            },{
                width: '80',
                title: '题目类型',
                field: 'sub_type',
                formatter: function (value, row, index) {
                        if (row.sub_type=='1'){
                            return '判断'
                        }else if (row.sub_type=='2'){
                            return '选择'
                        }else{
                            return '多选'
                        }

                    }
            },{
                width: '80',
                title: '选项A',
                field: 'a',
            }, {
                width: '80',
                title: '选项B',
                field: 'b',
            }, {
                width: '80',
                title: '选项C',
                field: 'c',
            }, {
                width: '80',
                title: '选项D',
                field: 'd',
            }, {
                width: '80',
                title: '答案',
                field: 'answer'
            },
            {
                width: '160',
                title: '解析文字',
                field: 'sub_infos'
            }, {
                width: '80',
                title: '解析图片',
                field: 'info_pic'
            }, {
                width: '80',
                title: '答题技巧',
                field: 'dtjq'
            }, {
                width: '80',
                title: '技巧语音',
                field: 'jqyy'
            },{
                width: '80',
                title: 'VIP解析图片',
                field: 'vip_pic'
            }, {
                width: '80',
                title: '更新时间',
                field: 'pubtime',
                sortable: true
            },{
                width: '80',
                title: '地市',
                field: 'city'
            }, {
                field: 'action',
                title: '操作',
                width: 130,
                formatter: function (value, row, index) {
                    var str = '';
                    str += $.formatString('<a href="javascript:void(0)" class="user-easyui-linkbutton-del"  onclick="deleteFun(\'{0}\');" >删除</a>', row.sub_id);
                    return str;
                }
            }]],
            onLoadSuccess: function (data) {
                $('.user-easyui-linkbutton-del').linkbutton({text: '删除', plain: true, iconCls: 'icon-del'});
            },
            toolbar: '#toolbar'
        });
            })

        //新增用户
        function addFun() {

            $("#userForm").form("clear");
            $("#userDialog").dialog("open");
        }

        //修改
        function editFun() {
			 var rows= dataGrid.datagrid('getSelected');

				if(rows == "undefined"||rows == null){
					HdUtil.messager.info("请选中编辑行");
					return;
				}
		        //= dataGrid.datagrid('getSelected');
                // id = rows.id;

            $("#userForm").form("clear").form("load", rows);
            $("#userDialog").dialog("open");
        }

        //保存
        function saveUser() {
            $("#userForm").form("submit", {
                url: "/updatetiku",
                onSumbit: function () {
                    $("#userForm").form.validate();
                },
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == "0") {
                        $("#userDialog").dialog("close");
                        HdUtil.messager.slide(data.msg);
                        $("#dataGrid").datagrid("reload");
                    } else {
                        $("#userDialog").dialog("close");
                        HdUtil.messager.error(data.msg);
                    }
                }
            });
        }
        //删除
        function deleteFun(sub_id) {
            $.messager.confirm(HdUtil.constant.CONFIRM, HdUtil.constant.DELETE_CONFIRM, function (r) {
                    if (r) {
                        $.ajax({
                            method: "post",
                            url: "/deltiku",
                            data: {
                                sub_id: sub_id
                            },
                            success: function (data) {
                                if (data.code == "0") {
                                    HdUtil.messager.slide(HdUtil.constant.DELETE_SUCCESS);
                                    $("#dataGrid").datagrid("reload");
                                } else {
                                    HdUtil.messager.error(data.msg);
                                }
                            }
                        })
                    }
                });
        }
        function sortFun() {
			 var rows= dataGrid.datagrid('getSelected');

				if(rows == "undefined"||rows == null){
					HdUtil.messager.info("请选中编辑行");
					return;
				}
		        //= dataGrid.datagrid('getSelected');
                // id = rows.id;

            $("#sortForm").form("clear").form("load", rows);
            $("#sortDialog").dialog("open");
        }

        //修改sortid
        function savesort() {
            $("#sortForm").form("submit", {
                url: "/updatesortid",
                onSumbit: function () {
                    $("#sortForm").form.validate();
                },
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == "0") {
                        $("#sortDialog").dialog("close");
                        HdUtil.messager.slide(data.msg);
                        $("#dataGrid").datagrid("reload");
                    } else {
                        $("#sortDialog").dialog("close");
                        HdUtil.messager.error(data.msg);
                    }
                }
            });
        }

        function searchFun() {
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }
        function cleanFun() {
            $('#searchForm input').val('');
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }

    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">

<div data-options="region:'center',border:true,title:'信息列表'">
  <table id="dataGrid" data-options="fit:true,border:false">
  </table>
</div>
<div id="toolbar" style="display: none;">
    <form id="searchForm">
        <table>
            <td><input id="keyword" name="keyword" placeholder="请输入关键词"/></td>
            <td><input id="sub_id" name="sub_id" type="hidden" /></td>

            <td>


            <a href="javascript:void(0);" class="easyui-linkbutton"
               data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">查询</a>
            <a href="javascript:void(0);" class="easyui-linkbutton"
                    data-options="iconCls:'icon-cancel',plain:true" onclick="cleanFun();">清空</a>

            <a onclick="addFun();" href="javascript:void(0);" class="easyui-linkbutton"
               data-options="plain:true,iconCls:'icon-add'">添加</a>
            <a onclick="editFun();" href="javascript:void(0);" class="easyui-linkbutton"
               data-options="plain:true,iconCls:'icon-edit'">编辑</a>
            <a onclick="sortFun();" href="javascript:void(0);" class="easyui-linkbutton"
               data-options="plain:true,iconCls:'icon-edit'">修改排序</a>
        </td>


        </table>
    </form></div>
<div id="userDialog">
    <form id="userForm" method="post">
        <table>
            <br/>
            <tr>
                <td style="vertical-align: middle">题目ID：</td>
                <td>
                    <input name="sub_id" class="easyui-textbox" data-options="required:true"/>
                    <input name="id" style="display:none">
                </td>
                <td style="vertical-align: middle">科目：</td>
                <td>
                    <select id="exam_type" class="easyui-combobox" name="exam_type" style="width:150px;"
                            data-options="panelHeight:50">
                        <option value="1">科目一</option>
                        <option value="4">科目四</option>
                    </select>
                </td>
                <td style="vertical-align: middle">章节：</td>
                <td>
                    <input name="sub_chapte" class="easyui-textbox" data-options="required:true"/>
                </td>
            </tr>
            <tr>

                <td style="vertical-align: middle">车辆类型：</td>
                <td>
                    <input name="car_type" class="easyui-textbox" data-options="required:true"/>
                </td>
                <td style="vertical-align: middle">题目类型：</td>
                <td>
                    <select id="sub_type" class="easyui-combobox" name="sub_type" style="width:150px;"
                            data-options="panelHeight:50">
                        <option value="1">判断</option>
                        <option value="2">选择</option>
                    </select>
                </td>
                <td style="vertical-align: middle">题目属性：</td>
                <td>
                    <input name="sub_class" class="easyui-textbox" data-options="required:true"/>
                </td>
                <td style="vertical-align: middle">VIP类型：</td>
                <td>
                    <input name="vip" class="easyui-textbox"/>
                </td>
            </tr>

            <tr>
                <td style="vertical-align: middle">题目：</td>
                <td>
                    <input name="sub_title" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">题目图片：</td>
                <td>
                    <input name="sub_pic" class="easyui-textbox"/>
                </td>

            </tr>
            <tr>
                <td style="vertical-align: middle">选项  A：</td>
                <td>
                    <input name="a" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">B：</td>
                <td>
                    <input name="b" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">C：</td>
                <td>
                    <input name="c" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">D：</td>
                <td>
                    <input name="d" class="easyui-textbox"/>
                </td>
            </tr>
            <tr>
                <td style="vertical-align: middle">答案:</td>
                <td>
                    <select id="answer" class="easyui-combobox" name="answer" style="width:150px;"
                            data-options="panelHeight:50">
                        <option value="A">A</option>
                        <option value="B">B</option>
                        <option value="C">C</option>
                        <option value="D">D</option>
                    </select>
                </td>
            </tr>
			<tr>
                <td style="vertical-align: middle">解析：</td>
                <td>
                    <input name="sub_infos" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">解析图片：</td>
                <td>
                    <input name="info_pic" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">VIP解析图片：</td>
                <td>
                    <input name="vip_pic" class="easyui-textbox"/>
                </td>
            </tr>
            <tr>
                <td style="vertical-align: middle">答题技巧：</td>
                <td>
                    <input name="dtjq" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">技巧语音：</td>
                <td>
                    <input name="jqyy" class="easyui-textbox"/>
                </td>
                <td style="vertical-align: middle">地市：</td>
                <td>
                    <input name="city" class="easyui-textbox"/>
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="sortDialog">
    <form id="sortForm" method="post">
        <table>
            <br/>
            <tr>
                <td style="vertical-align: middle">排序ID：</td>
                <td>
                    <input name="order_id" class="easyui-textbox" data-options="required:true"/>
                    <input name="sub_id" style="display:none">
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
